<?php
/*
 * Created on 28.09.2007 by Nikolai Plath
 *
 * * @file:bindex.html.php
 */

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

class HTML_BIndex
{
	
	function biHeader ($text)
	{	
		global $mainframe;
		
#		$mainframe->appendPathWay($text);
		$mainframe->appendPathWay("<a href='index.php' title='lol' class='pathway'>wow</a>&nbsp;");
		
#		print_a( $mainframe->getCustomPathway());
	?>
<div class="contentheading"><?php echo $text; ?></div>
		<?php
	} //function
	

	function _menuStart ()
	{ ?>

<div class="bi_menu">
	<table>
		<tr valign="bottom">
		<?php
	} //function
	
	function _menuEnd ()
	{ ?>

		</tr>
	</table>
</div>
		<?php
	} //function
	
	function _menuButton ( $link = FALSE, $x_task, $image, $text, $popup = FALSE, $JS = FALSE, $alt_conf = NULL, $task_add = '' )
	{ 
		global $task;
		global $biConfig;
		$selected = '';
		$onclick = '';
		if(! isset($biConfig)) $biConfig = $alt_conf;
	
		$alt = ' alt="'.$text.'" title="'.$text.'" ';

		if( $popup || $JS )
		{
			$onclick = 'onclick="';
			if( $popup ) $onclick .='return popup(this,550,600,1);';
			if( $JS ) $onclick .= $JS;
			$onclick .= '" ';
		} //if

		if( $x_task != '' ) $link .= '&amp;task='.$x_task.$task_add;
		$link = ($link) ? 'href="'.$link.'" ' : '';
		
		if( $task == $x_task ) $selected = '_selected';
		?>
		<td width="1%" nowrap="nowrap">
			<a class="bi_menu_button<?php echo $selected; ?>" <?php echo $link . $onclick; ?> >
				<?php
				if( $biConfig->buttonsShow == 'icons' || $biConfig->buttonsShow == 'both')
				{
				echo "\n".'<img src="components/com_bindex/images/menu/'.$biConfig->iconSet.'_'.$image.'" '.$alt.' border="0" />';
				} //if
				if( $biConfig->buttonsShow == 'both' ) echo '<br />';
				if( $biConfig->buttonsShow == 'text' || $biConfig->buttonsShow == 'both' ) echo $text; 
				 ?>
			</a>
		</td>
		<?php
	} //function
	
	function biMenu ()
	{ 
		global $Itemid, $task, $option;
		global $biConfig;
		global $popup, $id_bereich, $id_stadt;
		if( $biConfig->showMenuNotLoggedIn == 0 && ! canEdit() ) return;
		if( $popup ) return;
		
		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_help = 'index2.php?option=com_bindex&amp;Itemid='.$Itemid.'&amp;help='.$task;
		$this->_menuStart();//<--START
		$this->_menuButton( $link_base, 'bindex', 'home.png', BI_TITEL); 

		if( canEdit() )
		{
			$this->_menuButton( $link_base.'&amp;bid=0', 'edit', 'add.png', BI_NEW_ENTRY );
			$this->_menuButton( $link_base, 'trans_status', 'trans.png', BI_TRANS_STATUS );
			$this->_menuButton( $link_base, 'cats', 'folder.png', BI_CATEGORIES );
			$this->_menuButton( $link_base, 'templates', 'templates.png', BI_TEMPLATES );
			$this->_menuButton( $link_base, 'edit_config', 'config.png', BI_SETTINGS );
			$this->_menuButton( $link_help, 'help', 'help.png', BI_HELP, TRUE );
			$this->_menuEnd();
		}
		if( !canEdit() )
		{
		$this->_menuButton( $link_base, 'map', 'map.png', BI_MAP );
		$this->_menuButton( $link_base, 'search', 'search.png', BI_SEARCH );
		$this->_menuEnd();//<--END
		}
		if( canEdit() && ( ( $task == 'bindex') || ( $task == 'map') || ( $task == 'search') || ( $option == 'com_bindex' && $task == '') ) )
		{ ## submenu
		$s_bereich = ( $id_bereich > 0 ) ? '&amp;id_bereich='.$id_bereich : '';
		$s_stadt = ( $id_stadt > 0 ) ? '&amp;id_stadt='.$id_stadt : '';
		$this->_menuStart();
		$this->_menuButton( $link_base, 'bindex', 'home.png', BI_TITEL, FALSE, FALSE, NULL, $s_bereich.$s_stadt ); 
		$this->_menuButton( $link_base, 'map', 'map.png', BI_MAP, FALSE, FALSE, NULL, $s_bereich.$s_stadt  );
		$this->_menuButton( $link_base, 'search', 'search.png', BI_SEARCH );
		$this->_menuEnd();//<--END
			
		} //if
		if( canEdit() && ( $task == 'cats') )
		{ ## submenu
			$this->_menuStart();//<--START
			$this->_menuButton( $link_base, 'bereiche', 'folder_red.png', BI_SECTIONS );
			$this->_menuButton( $link_base, 'staedte', 'folder_yellow.png', BI_CITIES );
			$this->_menuEnd();//<--END
		} //if

	} //function
	
	function listBereiche( $rows_ids, $pageNav, $limitstart, $limit )
	{
		global $database, $Itemid;
		global $langActive;
		global $GMap;
//		global $biConfig;
		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_back = $link_base.'&amp;task=bereiche'; 
		$link_edit = $link_base.'&amp;task=edit_bereich';

		$this->biHeader(BI_SECTIONS);

		if( count( $rows_ids ) )
		{
			?>
			<table width="100%" align="center" style="border: 1px solid black;">
				<tr>
					<td align="left" class="sectiontablefooter">
						<?php
						echo _PN_DISPLAY_NR . '&nbsp;';
						echo $pageNav->getLimitBox($link_back);
						?>
					</td>
				
					<td align="center" class="sectiontablefooter">
						<?php echo $pageNav->writePagesLinks($link_back); ?>
					</td>
				</tr>
				<tr align="center">
					<td colspan="2">
					<strong><?php echo $pageNav->writePagesCounter(); ?></strong>
					</td>
				</tr>
			</table>
			<table width="100%" style="border: 1px solid #000000;">
				<tr>
					<th><?php echo BI_ICON; ?></th>
					<?php $this->drawLanguageTHs(); ?>
					<th class="bi_action" width="7%"><?php echo BI_ACTION; ?></th>
				</tr>
			<?php
			$k = 0;
			foreach( $rows_ids as $r_id )
			{
				echo '<tr class="sectiontableentry'. ($k + 1) . '">';
				echo '<td>';
				$GMap->_drawGIconBereich( $r_id->id );
				echo '</td>';
				foreach( $langActive as $language )
				{
					$value = getValueBereich ($r_id->id, $language->code);
					echo ($value) ? "<td>$value</td>" : "<td style=\"background-color: red\">&nbsp;</td>";
				}//foreach
				echo '<td class="bi_action">';
				$this->drawEditImage($link_edit.'&amp;bid='.$r_id->id);
				echo '</td>';
				echo '</tr>';
				$k = 1 - $k;
			} //foreach
			?>
			</table>
			<?php
		} else
		{
			$this->msgInfo(BI_NO_DATA);
		} //if

		$this->formBereich();

	} //function
	
	
	function formBereich( $Bid = 0 )
	{
		global $Itemid;
		global $langActive;
		global $biConfig, $GMap;
//		$this->_initTabs();
		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
//		$link_back = $link_base.'&amp;task=bereiche';
		$link_save_bereich = $link_base.'&amp;task=save_bereich';
		$bereich = new bereich($Bid);
		if( $Bid )//bearbeiten
		{?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/edit_f2.png" alt="edit" />
				<?php echo BI_SEC_EDIT; ?>
			</div>
			<?php
		} else //neue
		{?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/new_f2.png" alt="neu" />
				<?php echo BI_SEC_NEW; ?>
			</div>
			<?php		
		}//if
		?>
		<form action="<?php echo $link_save_bereich; ?>" method="post" name="adminForm">
			<table width="100%" style="border: 1px solid #000000;">
			<?php
			foreach( $langActive as $language )
			{
				if( $Bid | $language->code == $biConfig->ini_language)
				{
					?>
					<tr style="background-color: #F2F2FF">
						<td align="right">
							<?php echo $language->name.'&nbsp;'; $this->_drawFlagImage($language->iso); ?>
						</td>
						<th align="right"><?php echo BI_SEC_NAME; ?></th>
						<td>
							<input type="text" name="name_<?php echo $language->code; ?>" size="20"
								  value="<?php echo getValueBereich ($Bid, $language->code); ?>" />
						</td>
					</tr>
					<?php 
				}//if
			}//foreach
			?>
				<tr style="background-color: #F2F2FF">
					<td colspan="2">
						<?php $GMap->_drawGIconSelector( $bereich->icon_pal, $bereich->icon_no, $bereich->icon_name ); ?>

					
					</td>
					<td>
						<div align="center">
							<input type="submit" class="button" value="<?php echo BI_SAVE; ?>" />
						</div>
					</td>
				</tr>
				<tr style="background-color: #F2F2FF">
					<td colspan="3">
					</td>
				</tr>
			</table>
			<input type="hidden" name="bid" value="<?php echo $Bid; ?>" />
		</form>

		<?php
	} //function
	
		function listStaedte( $rows_ids, $pageNav, $limitstart, $limit )
	{
		global $database, $Itemid;
		global $langActive;
		global $biConfig;

		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_back = $link_base.'&amp;task=staedte';
		$link_edit = $link_base.'&amp;task=edit_stadt';
		$this->biHeader(BI_CITIES);
		
		if( count( $rows_ids ) )
		{
			?>
			<table width="100%" align="center" style="border: 1px solid black;">
				<tr>
					<td align="left" class="sectiontablefooter">
						<?php
						echo _PN_DISPLAY_NR . '&nbsp;';
						echo $pageNav->getLimitBox($link_back);
						?>
					</td>
				
					<td align="center" class="sectiontablefooter">
						<?php echo $pageNav->writePagesLinks($link_back); ?>
					</td>
				</tr>
				<tr align="center">
					<td colspan="2">
					<strong><?php echo $pageNav->writePagesCounter(); ?></strong>
					</td>
				</tr>
			</table>
			<table width="100%" style="border: 1px solid #000000;">
				<tr>
					<th class="bi_langbox"><?php echo BI_SECTION; ?></th>
					<?php $this->drawLanguageTHs(); ?>
					<th class="bi_action" width="7%"><?php echo BI_ACTION; ?></th>
				</tr>
			<?php
			$k = 0;
			foreach( $rows_ids as $r_id )
			{ ?>
				<tr class="sectiontableentry<?php echo ($k + 1); ?>">
					<td class="bi_action" style="text-align: left">
						<?php echo getValueBereich($r_id->id_bereich, $biConfig->ini_language); ?>
					</td>
				<?php
				foreach( $langActive as $language )
				{
					$value = getValueStadt ($r_id->id, $language->code);
					echo ($value) ? "\n<td>$value</td>" : "\n<td style=\"background-color: red\">&nbsp;</td>";
				}//foreach
				?>
					<td class="bi_action" style="text-align: center">
						<?php $this->drawEditImage($link_edit.'&amp;bid='.$r_id->id); ?>
					</td>
				</tr>
				<?php
				$k = 1 - $k;
			} //foreach
			?>
			</table>
			<?php
		} else
		{
			$this->msgInfo(BI_NO_DATA);
		} //if
		$this->formStadt();
	} //function
	
	function formStadt( $Bid = 0, $id_bereich = 0 )
	{
		global $Itemid;
		global $langActive;
		global $biConfig;
		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_back = $link_base.'&amp;task=staedte';
		$link_save = $link_base.'&amp;task=save_stadt';

		if( $Bid )//bearbeiten
		{?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/edit_f2.png" alt="edit" />
				<?php echo BI_CITY_EDIT; ?>
			</div>
			<?php	
		} else //neue
		{?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/new_f2.png" alt="neu" />
				<?php echo BI_CITY_NEW; ?>
			</div>
			<?php
		}//if
		?>
		<form action="<?php echo $link_save; ?>" method="post" name="adminForm">
			<table width="100%" style="border: 1px solid #000000;">
				<tr style="background-color: #F2F2FF">
					<td>&nbsp;</td>
					<th align="right"><?php echo BI_SECTION; ?></th>
					<th><?php $this->drawSelectListBereiche( $id_bereich ); ?></th>
			 	</tr>
				<?php
				foreach( $langActive as $language )
				{
					if( $Bid | $language->code == $biConfig->ini_language)
					{
				?>
				<tr style="background-color: #F2F2FF">
					<td align="right">
						<?php echo $language->name; $this->_drawFlagImage($language->iso); ?>
					</td>
					<th align="right"><?php echo BI_SEC_NAME; ?></th>
					<td>
						<input type="text" name="name_<?php echo $language->code; ?>" size="20"
							  value="<?php echo getValueStadt ($Bid, $language->code); ?>" />
					</td>
				</tr>
				<?php }//if
				}//foreach
				?>
				<tr style="background-color: #F2F2FF">
					<td colspan="3">
						<div align="center">
							<input type="submit" class="button" value="<?php echo BI_SAVE; ?>" />
						</div>
					</td>
				</tr>
			</table>
			
			<input type="hidden" name="bid" value="<?php echo $Bid; ?>" />

		</form>
	<?php
	} //function
	
	function bindexItem( $Bid, $Bid_ref, $popup = FALSE )
	{
		global $mainframe, $Itemid, $mosConfig_lang;
		global $biConfig;
		
		if( ! $biConfig->GMapShowPopup ) $popup = FALSE;

		$item = new biItem( $Bid, $Bid_ref);

		
		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_edit = $link_base.'&amp;task=edit&amp;bid='.$Bid->id_item;
		if( canEdit() && ! $popup ) $this->drawEditImage( $link_edit );
		$mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="'.$biConfig->templatePath.'item/'.$biConfig->templateItem.'.css" />');

		if( $popup )
		{
			#Display popup
			
			$item->mapLocation($biConfig->GMapPopupWidth, $biConfig->GMapPopupHeight, 'info', $biConfig->GMapPopupZoom, $popup );
		} else
		{
			#################################################################################################
			#     Get the template                                                                ########
#############                                                             #######################
			require_once($biConfig->templatePath.'item/'.$biConfig->templateItem.'.php'); #########
#############			                                                  #######################
			#                                                                                     ########
			#################################################################################################
		}
	} //function
	
	function bindex( $Bs, $Bs_ref, & $pageNav, & $lists, $order )
	{
//	echo "<hr />Bs";print_r( $Bs);echo "<hr />BS_REF";print_r( $Bs_ref);echo "<hr />";
		
		global $mainframe, $Itemid, $my, $mosConfig_lang;//, $mosConfig_absolute_path;
		global $statmsg;
		global $biConfig, $id_stadt, $id_bereich;
		global $GMap;
global $DBG;
		//mosCommonHTML :: loadOverlib();
		$this->load_JS_Lightbox();
		$from_task='';//TODO NiK
		if ($order == '') $order = 'gesamt';
		$filter = '';
		if ($lists['filter']) $filter = '&amp;filter=' . $lists['filter'];

		$link_base = 'index.php?option=com_bindex&amp;Itemid=' . $Itemid;
		$link_all = $link_base.'&amp;order=' . $order . $filter;
		$link_back = $link_base
				.'&amp;id_bereich='.$id_bereich
				.'&amp;id_stadt='.$id_stadt; 

$DBG->out( '$order: '.$order );
$DBG->out( '$filter: '.$lists['filter'] );
		

	if( $id_bereich > 0 )
	{
		$bereich = new bereich( $id_bereich, $mosConfig_lang );
		echo '<div class="gmap_header">'.$GMap->_drawGIconBereich($id_bereich, FALSE).'&nbsp;&nbsp;'.$bereich->name.'</div>';
	} elseif( $id_stadt > 0)
	{
		$o_id_bereich = getBereichFromIDstadt( $id_stadt );
		$id_bereich = $o_id_bereich->id;
		$bereich = new bereich( $id_bereich, $mosConfig_lang );
		echo '<div class="gmap_header">'.$GMap->_drawGIconBereich($id_bereich, FALSE).'&nbsp;&nbsp;'.$bereich->name.' / '.getValueStadtOrDefault($id_stadt,$mosConfig_lang).'</div>';
	} //if
?>

		<form action="<?php echo sefRelToAbs($link_back); ?>" method="post" name="adminForm">
			<?php //$this->drawSelectListBereiche($id_bereich, TRUE); ?>
			<?php //$this->drawSelectListStaedte($id_stadt, TRUE); ?>
			<?php
			if ( count($Bs) )
			{
			?>
			<table width="100%" align="center" style="border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;">
				<tr>
					<td align="center" class="sectiontablefooter">
						<?php
						echo _PN_DISPLAY_NR . '&nbsp;';
						echo $pageNav->getLimitBox($link_back);
						?>
					</td>
					<td align="center" class="sectiontablefooter">
						<?php echo $pageNav->writePagesLinks($link_back); ?>
					</td>
				</tr>
			</table>
			<?php
			} //if
			?>
		</form>
		<?php

		if ( !count($Bs) )
		{ $this->msgInfo(BI_NO_DATA);
		} else
		{
			?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr align="center">
					<td style="border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black;">
					<strong><?php echo $pageNav->writePagesCounter(); ?></strong>
					</td>
				</tr>
			</table>


			<?php
			switch( $biConfig->viewMode )
			{
				case 'list':
				$this->_bindex_listView( $Bs, $Bs_ref, $link_base );
				break;
				case 'directory':
				$this->_bindex_directoryView( $Bs, $Bs_ref, $link_base );
				break;
				default:
					echo 'undefined..'.$biConfig->viewMode;
				break;	
			} //switch

		}//if
	} //function
	
	function _bindex_listView ( $Bs, $Bs_ref, $link_base )
	{
		global $mosConfig_lang;
		global $biConfig;	
				
				?>
				<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;">
				<tr>
					<th width="10%" >&nbsp;</th>
					<th width="5%" align="center">I</th>
					<th width="5%" align="center">M</th>
					<th><?php echo BI_NAME; ?></th>
					<th><?php echo BI_CITY; ?></th>
					<?php
					if( canEdit() )
					{ ?>
						<th class="bi_action" colspan="2" width="10%"><?php echo BI_ACTION; ?></th>
						<?php
					} //if
					?>
				</tr>
				<?php
				$k = 0;
				$i = 0;
				foreach ($Bs as $dsatz)
				{
					$dsatz_ref = $Bs_ref[$i];
					$link_item = $link_base.'&amp;bid='.$dsatz_ref->id_item; 
					$link_view = $link_item.'&amp;task=view';
					$link_edit = $link_item.'&amp;task=edit';
					$link_kill = $link_item.'&amp;task=kill';
					$link_stadt = $link_base.'&amp;task=bindex&amp;id_stadt='.$dsatz->id_stadt;
					$bild_pfad = $biConfig->imagesFolder.'tmb_'.$dsatz_ref->bild;
					
					$item = new biItem($dsatz, $dsatz_ref);
					?>
				<tr class="sectiontableentry<?php echo $k + 1; ?>">
<!-- TEMPLATE START -->
					<td align="center"><?php $item->image( FALSE, TRUE, FALSE, $link_view ); ?></td>
					<td align="center"><?php	$item->drawBindexTTinfo($link_view); ?></td>
					<td align="center"><?php $item->drawGlobe( $link_view ); ?></td>
					<td><?php $item->name( FALSE, $link_view ); ?></td>
					<td><?php $item->city(); ?></td>
					<td align="center"><?php $item->drawEdit( $link_edit ); ?></td>
					<td align="center"><?php $item->drawKill( $link_kill ); ?></td>
<!-- TEMPLATE END -->					
					
				</tr>
				<?php	
				$k = 1 - $k;
				$i++;
			} //foreach
			?>
			</table>
		<?php
	} //function



	function _bindex_directoryView ( $Bs, $Bs_ref, $link_base )
	{
		global $mainframe, $mosConfig_lang;
		global $biConfig;	
				$itemsInRow = $biConfig->directory_items_in_row;
				?>
				<table width="100%" border="0" cellspacing="5" cellpadding="0" >
				<tr>
				<?php
				$k = 0;
				$i = 0;
				$cnt_itemsInRow = 1;
				foreach ($Bs as $dsatz)
				{
					$dsatz_ref = $Bs_ref[$i];
					$link_item = $link_base.'&amp;bid='.$dsatz_ref->id_item; 
					$link_view = $link_item.'&amp;task=view';
					$link_edit = $link_item.'&amp;task=edit';
					$link_kill = $link_item.'&amp;task=kill';
					$link_stadt = $link_base.'&amp;task=bindex&amp;id_stadt='.$dsatz->id_stadt;
					$bild_pfad = $biConfig->imagesFolder.'tmb_'.$dsatz_ref->bild;
					
					$item = new biItem($dsatz, $dsatz_ref);
					$mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="'.$biConfig->templatePath.'directory/'.$biConfig->templateDirectory.'.css" />');
					?>
					<td class="bi_directory_item_cell" width="<?php echo intval(100/$itemsInRow); ?>%">
<?php
			#################################################################################################
			#     Get the template                                                                ########
#############                                                             #######################
echo "\n\n<!-- TEMPLATE START -->\n\n";
			include($biConfig->templatePath.'directory/'.$biConfig->templateDirectory.'.php'); #########
echo "\n\n<!-- TEMPLATE END -->\n\n";
#############			                                                  #######################
			#                                                                                     ########
			#################################################################################################
?>
<!--
<table width="100%">
	<tr>
		<td colspan="2">
			<?php $item->name( FALSE, $link_view ); ?>
		</td>
	</tr>
	<tr>
		<td align="center" width="10%">
			<?php $item->image( FALSE, TRUE, FALSE, $link_view ); ?>
		</td>
		<td>
			<?php $item->street(); ?>&nbsp;<?php $item->street_number(); ?> <br />
			<?php $item->city(); ?>
			<div align="right">	
				<?php
				$item->drawGlobe( $link_view );
				$item->drawBindexTTinfo($link_view);
				$item->drawEdit( $link_edit );
				$item->drawKill( $link_kill );
				
				?>
			</div>
		</td>
	</tr>
</table>

 TEMPLATE END -->


		 			</td>
		 			<?php
					if( $cnt_itemsInRow >= $itemsInRow )
					{
					?>
				</tr>
				<tr>
				<?php	
					$cnt_itemsInRow = 1;
					} else
					{
				$cnt_itemsInRow++;
					
					} //if
				$k = 1 - $k;
				$i++;
			} //foreach
			
			###filler
			for ($ix = $cnt_itemsInRow-1; $ix < $itemsInRow; $ix++) {
				echo '<td>&nbsp;</td>';
			}
			
			?>
			</tr>
			</table>
		<?php
	} //function

	function old_drawEdit ( $link )
	{
		if( canEdit() )
		{
			?>
			<a href="<?php echo $link; ?>">
				<img src="components/com_bindex/images/edit.png" border="0" alt="<?php echo BI_EDIT; ?>" title="<?php echo BI_EDIT; ?>" />
			</a>
			<?php	
		}//if
		
	} //function

	function old_drawBindexTTinfo ( $BIndex, $BIndex_ref, $link_view )
	{
		global $biConfig;
		
		if( ! $BIndex->beschreibung ) return;
		
		$title = ( $BIndex->name ) ? $BIndex->name : $BIndex_ref->name;
		$tooltip = '';
		
		$id =( $BIndex->id_item ) ? $BIndex->id_item : $BIndex_ref->id_item; 
		//$tooltip .= "($id)&lt;br /&gt;";
		$tooltip .= $BIndex->beschreibung;
		?>
		<a href="<?php echo $link_view; ?>" rel="balloon<?php echo $id; ?>">
			<img src="components/com_bindex/images/info.png" alt="info" border="0" />
		</a>
		
		<div id="balloon<?php echo $id; ?>" class="balloonstyle">
			<img src="components/com_bindex/images/info.png" alt="" style="float: right; margin-left: 5px;" />
			<?php echo $tooltip; ?>
		</div>

		<?php
	} //function
	
	function bindexTrans ( $items, $pageNav, $lists, $order   )
	{
		global $Itemid;
		global $langActive;
global $DBG;

		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		if ($order == '') $order = 'gesamt';
		$filter = '';
		if ($lists['filter']) $filter = '&amp;filter=' . $lists['filter'];

		$link_back = $link_base.'&amp;task=trans_status&amp;order=' . $order . $filter;

$DBG->out( '$order: '.$order );
$DBG->out( '$filter: '.$lists['filter'] );

		$this->biHeader(BI_ENTRIES);
		?>
		<form action="<?php echo sefRelToAbs($link_back); ?>" method="post" name="adminForm">
			<?php //$this->drawSelectListBereiche($id_bereich, TRUE); ?>
			<?php //$this->drawSelectListStaedte($id_stadt, TRUE); ?

		?>
			<table width="100%" align="center" style="border: 1px solid black;">
				<tr>
					<td align="left" class="sectiontablefooter">
						<?php
						echo _PN_DISPLAY_NR . '&nbsp;';
						echo $pageNav->getLimitBox($link_back);
						?>
					</td>
				
					<td align="center" class="sectiontablefooter">
						<?php echo $pageNav->writePagesLinks($link_back); ?>
					</td>
				</tr>
				<tr align="center">
					<td colspan="2">
					<strong><?php echo $pageNav->writePagesCounter(); ?></strong>
					</td>
				</tr>
			</table>
		<table width="100%" style="border: 1px solid black;">
			<tr>
				<?php $this->drawLanguageTHs(); ?>
				<th class="bi_action" width="7%"><?php echo BI_ACTION; ?></th>
			</tr>
		<?php

		$k = 0;
		foreach( $items as $Bs )
		{
					$link_item = $link_base.'&amp;bid='.$Bs[0]->id_item; 
					$link_view = $link_item.'&amp;task=view';
					$link_edit = $link_item.'&amp;task=edit&amp;from_task=trans_status';

			echo '<tr class="sectiontableentry'. ($k + 1) . '">';
			foreach( $langActive as $language )
			{
				$found = '';
				foreach( $Bs as $B )
				{
					if( $B->language == $language->code )
					{
						$found = $B->name;
					} //if
				}//foreach
				echo ( $found == '' ) ? '<td style="background-color: red"></td>' : "<td>$found</td>";
			}//foreach
			?>
			<td class="bi_action" width="7%" nowrap="nowrap">
				<a href="<?php echo $link_edit; ?>">
					<img src="components/com_bindex/images/edit.png" border="0" alt="<?php echo BI_EDIT; ?>" title="<?php echo BI_EDIT; ?>" />
				</a>
			</td>
		</tr>
			<?php	
			$k = 1 - $k;
		}//foreach
		?>
		</table>
	</form>
	<?php
//$DBG->out($items);
	} //function
	
	
	function formSearch ($id_bereich = 0, $id_stadt = 0, $name = '' )
	{
		global $Itemid;
echo($id_bereich);
		$link_submit = 'index.php?option=com_bindex&amp;task=search&amp;Itemid='.$Itemid;
		?>
		<form name="searchForm" action="<?php echo $link_submit; ?>" method = "post">
			<table>
				<tr>
					<td><?php echo BI_NAME; ?></td>
					<td>aa</td>
				</tr>
				<tr>
					<td><?php echo BI_SECTION; ?></td>
					<td><?php $this->drawSelectListBereiche( $id_bereich, TRUE, 'searchForm' ); ?></td>
				</tr>
				<tr>
					<td><?php echo BI_CITY; ?></td>
					<td><?php $this->drawSelectListStaedte( $id_stadt, TRUE, 'searchForm' ); ?></td>
				</tr>
			</table>
		</form>
		<?php
	} //function
	
	function formBIndex( $BIndexes = NULL, $from_task = '' )
	{
		global $mainframe, $mosConfig_lang, $Itemid;//, $mosConfig_live_site;
		global $langActive;
		global $biConfig, $GMap;
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$biConfig->liveSite.'/components/com_bindex/includes/js/tiny_mce/tiny_mce_src.js"></script>');
		$this->biInitEditor();
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$biConfig->liveSite.'/components/com_bindex/includes/js/tiny_init.js"></script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$biConfig->liveSite.'/components/com_bindex/includes/js/bindex_js.js"></script>');
		?>
<script type='text/javascript'>function copyField ( from_field, to_field ) { to_field.value = from_field.value; }</script>
		<?php

		/** Tabs and slides pluging*/
		$this->load_JS_Tabs_Slides();

		$link_base = 'index.php?option=com_bindex&amp;Itemid='.$Itemid;
		$link_save = $link_base.'&amp;task=save';
		
		
		if( !$BIndexes )
		{//neu
			?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/new_f2.png" alt="neu" />
				<?php echo BI_NEW_ENTRY; ?>
			</div>
			<div class="bi_info">
				<?php echo BI_NEW_ENTRY_DESC; ?>
			</div>
			<form enctype="multipart/form-data" action="<?php echo sefRelToAbs($link_save); ?>" method="post" name="BiForm" class="bi_form_edit">

				<?php $this->drawSelectListStaedte(); ?>
				<hr />

				<?php $this->drawBIForm( $biConfig->ini_language ); ?>

				<p><?php echo BI_ADDITIONAL_INFO; ?></p>
				
				
				<div class="jwts_title">
					<div class="jwts_title_left">
						<a href="javascript:void(null);" title="Click to open!" class="jwts_title_text"><?php echo BI_PICTURE; ?></a>
					</div>
				</div>
				<div class="jwts_slidewrapper">
					<div>
						<?php $this->_drawBildUpload( $BIndexes[0] ); ?>
					</div>
				</div>
				<div class="jwts_title">
					<div class="jwts_title_left">
						<a href="javascript:void(null);" title="Click to open!" class="jwts_title_text"><?php echo BI_MAP_ENTRY; ?></a>
					</div>
				</div>
				<div class="jwts_slidewrapper">
					<div class="gmap_selector">
						<?php $GMap->_drawGMapSelector( $BIndexes[0] ); ?>
						<?php $this->msgInfo( BI_GMAP_SELECT_DESC ); ?>
					</div>
				</div>
				



				<br style="clear: both;" />
				<br />
				<table width="100%">
					<tr align="center">
						<td><?php $this->_Button('javascript: document.BiForm.submit();', 'save', BI_SAVE ); ?></td>
						<td><?php $this->_Button($link_base, 'cancel', BI_CANCEL ); ?></td>
					</tr>
				</table>
				<br />
			</form>
			<?php
		} else
		{//EDIT
			?>
			<div class="bi_menu">
				<img src="components/com_bindex/images/edit_f2.png" alt="edit" />
				<?php echo BI_EDIT; ?>
			</div>
			<form enctype="multipart/form-data" action="<?php echo sefRelToAbs($link_save); ?>" method="post" name="BiForm" class="bi_form_edit">
							<?php $this->drawSelectListStaedte($BIndexes[0]->id_stadt); ?>
							<hr />
			
				<table width="100%">
					<tr valign="top">
						<td>
							<div class="jwts_tabber" id="jwts_tab1">
								<div class="jwts_tabbertab" title="">
									<h2><a href="javascript:void(null);" name="advtab"><?php echo $biConfig->ini_language; ?></a></h2>

									<?php $this->drawBIForm( $biConfig->ini_language, $BIndexes ); ?>

								</div>
							</div>
						</td>
						<td>
							<div class="jwts_tabber" id="jwts_tab">
								<?php
								//$tab_count = 1;
								foreach( $langActive as $language )
								{
									if( $language->code != $biConfig->ini_language )
									{?>
						 				<div class="jwts_tabbertab" title="">
											<h2><a href="javascript:void(null);" name="advtab"><?php echo $language->name; ?></a></h2>

											<?php $this->drawBIForm( $language->code, $BIndexes ); ?>

										</div>
										<?php
									} //if
								}//foreach
								?>
							</div>
						</td>
					</tr>
				</table>
				
				<hr />
				<div class="jwts_tabber" id="jwts_tab_add">
					<div class="jwts_tabbertab" title="">
						<h2><a href="javascript:void(null);" name="advtab"><?php echo BI_PICTURE; ?></a></h2>
						<?php $this->_drawBildUpload( $BIndexes[0] ) ?>
					</div>
					<div class="jwts_tabbertab" title="">
						<h2><a href="javascript:void(null);" name="advtab"><?php echo BI_MAP_ENTRY; ?></a></h2>
							<?php $GMap->_drawGMapSelector( $BIndexes[0] ); ?>
							<?php $this->msgInfo( BI_GMAP_SELECT_DESC ); ?>
					</div>
				</div>
			
				<hr />
				<br />
				<br />
				<div align="center" style="clear: both">
				<table width="50%">
					<tr>
				<td align="center"><?php $this->_Button('javascript: document.BiForm.submit();', 'save', BI_SAVE ); ?></td>
				<td align="center"><?php $this->_Button($link_base, 'cancel', BI_CANCEL ); ?></td>

				</tr>
				</table>
				</div>
				
				<input type="hidden" name="from_task" value="<?php echo $from_task; ?>" />
			
			</form>
			<?php
		} //if
	} //function
	
	function _Button ( $link, $task, $text )
	{
		?>
			<a class="bi_button<?php echo $task; ?>" href="<?php echo $link; ?>">
				<?php echo $text; ?>
			</a>
		<?php
		
	} //function
	
	/**
	 * @param int $editor_width
	 */
	function biInitEditor( $width = 0, $height = 0)
	{ 
		global $biConfig;
		?>
		<script type="text/javascript">
		<!--
		tinyMCE.init({
					mode : 'textarea',
					theme : 'advanced',
					theme_advanced_buttons1 : 'bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull',
					theme_advanced_buttons2 : 'hr,link,separator,bullist,numlist,undo,redo',
					theme_advanced_buttons3 : '',
					theme_advanced_toolbar_location : 'top',
					theme_advanced_toolbar_align : 'left',
					width : '<?php echo( $width ) ? $width : $biConfig->editorWidth; ?>',
					height : '<?php echo( $height ) ? $height : $biConfig->editorHeight; ?>',
					extended_valid_elements : 'a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]',
				});
		-->
		</script>
		<?php
	} //function
	
	function drawBIForm ( $language_code, $BIndexes = NULL )
	{
		global $Itemid, $database, $mainframe;//, $mosConfig_live_site;
		global $biConfig;

		$link_back_JS = 'index.php?option=com_bindex&Itemid='.$Itemid.'&amp;bi_lang='.$language_code;
		$link_base = 'index.php?option=com_bindex&amp;Itemid=' . $Itemid.'&amp;bi_lang='.$language_code;
		$link_save = $link_base.'&amp;task=save';

		if( !$BIndexes )#bearbeiten
		{ $BIndex = new bindex( $database );
		} else
		{
			foreach( $BIndexes as $b )
			{
				if( $b->language == $language_code )
				{#language found
					$BIndex = $b;
				} //if
			}
			if( ! isset($BIndex) )
			{#Nothing found... must be new
				$BIndex = new bindex( $database );
			} //if
		}//if
		?>
			<table width="100%">
				<tr>
					<th><?php $this->_drawFlagImage(getLanguageISO($language_code)); ?></th>
				</tr>
				<tr style="background-color: #F2F2FF">
					<td>
						<?php echo BI_NAME; $this->_drawRequired(); ?><br />
						<?php $this->drawCopyButtonJS( 'name', $language_code); ?>
						<input type="text" name="name_<?php echo $language_code; ?>" size="20" value="<?php echo $BIndex->name; ?>" />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo BI_STREET; ?><br />
						<?php $this->drawCopyButtonJS( 'strasse', $language_code); ?>
						<input type="text" name="strasse_<?php echo $language_code; ?>" size="20" value="<?php echo $BIndex->strasse; ?>" />
						<!-- <div align="right"> -->
							<br />
							<?php $this->drawCopyButtonJS( 'hausnummer', $language_code); ?>
							<?php echo BI_STREET_NO; ?>&nbsp;
							<input type="text" name="hausnummer_<?php echo $language_code; ?>" size="5" value="<?php echo $BIndex->hausnummer; ?>" />
						<!-- </div> -->
					</td>
				</tr>
				<tr>
					<td>
						<?php echo BI_TELEFONE; ?><br />
						<?php $this->drawCopyButtonJS( 'telefon', $language_code); ?>
						<input type="text" name="telefon_<?php echo $language_code; ?>" size="20" value="<?php echo $BIndex->telefon; ?>" />
					</td>
				</tr>
				<tr>
					<td><?php echo BI_FAX; ?><br />
						<?php $this->drawCopyButtonJS( 'fax', $language_code); ?>
						<input type="text" name="fax_<?php echo $language_code; ?>" size="20" value="<?php echo $BIndex->fax; ?>" />
					</td>
				</tr>
				<tr>
					<td><?php echo BI_EMAIL; ?><br />
						<?php $this->drawCopyButtonJS( 'email', $language_code); ?>
						<input type="text" name="email_<?php echo $language_code; ?>" size="20" value="<?php echo $BIndex->email; ?>" />
					</td>
				</tr>
				<tr>
					<td><?php echo BI_DESCRIPTION; ?><br />
						<?php //$this->drawCopyButtonJS( 'beschreibung', $language_code);
						 ?>
						<textarea rows="10" cols="40"  id="beschreibung_<?php echo $language_code; ?>" name="beschreibung_<?php echo $language_code; ?>">
							<?php echo $BIndex->beschreibung; ?>
						</textarea>
						<script type="text/javascript">setTextareaToTinyMCE('beschreibung_<?php echo $language_code; ?>')</script>
					</td>
				</tr>
			</table>
			<input type="hidden" name="bid_<?php echo $language_code; ?>" value="<?php echo $BIndex->id_item; ?>" />
			<?php

			$this->_drawRequiredDesc();

	}//function
	
	
	
	function _drawBildUpload( $BIndex = NULL )
	{
	//	global $mosConfig_live_site;
		global $biConfig;
		
	//	$ret = '';
		?>
		<div id="fotobox">
		<?php
				if( $BIndex && strlen( $BIndex->bild ) != 0)
				{
				$img = $biConfig->liveSite.$biConfig->imagesFolder.$BIndex->bild;
				?>
				
					<strong><?php echo BI_PICTURE; ?></strong><br />
				

<a href="meinbild.jpg"><img src="<?php echo $img; ?>" alt="<?php echo $img; ?>"/></a>
<br style="clear:both" />

				
				
				
				
				
				<br/>
				<input type="checkbox" name="bindexImgDelete" id="bindexImgDelete"  value="1"
						onclick="if( this.checked==false) {
	    					bindexImg.value = '';
	    					bindexImg.disabled = false
	    					}
	    					else {
	    					bindexImg.value = '';
	    					bindexImg.disabled = true
	    					}"
	    					/>
	    		<label for="bindexImgDelete"><?php echo BI_DELETE; ?></label>
	    		<br />
				<?php
				} //if
				?>
	    		<input name='bindexImg' id='bindexImg' class='inputbox' type='file' size='20' maxlength='100000' accept='text/*'/>
</div>
				<?php
	} //function
	
	
	/**
	 * Helpers
	 */
	
	function _drawRequiredDesc ()
	{
		echo '<div>';
		$this->_drawRequired();
		echo '&nbsp;-&nbsp;'.BI_REQUIRED_DESC;
		echo '</div>';
	} //function
	
	function _drawFlagImage( $language_code )
	{
	//	global $mosConfig_live_site;
	global $biConfig;
		$src = $biConfig->liveSite."/components/com_joomfish/images/flags/".$language_code.".gif";
		echo '<img src="'.$src.'" alt="flag'.$language_code.'" />';
	} //function
	
	function _drawGmapLoaderDIV ()
	{?>
		<div id="gmap_loader" class="gmap_loader">
		gmap wird geladen...
		</div>
		<?php
	} //function
	
	function drawInfoTT ($text, $title = null)
	{
		
		global $biConfig;
		
		//$title = $this->name(true);
		$tooltip = '';
		$link_view = '#';
		
		//$id =( $this->B_ref->id_item ); 
		//$tooltip .= "($id)&lt;br /&gt;";
		$tooltip .= $text;//$this->description(TRUE);
		?>
		<a href="<?php echo $link_view; ?>" rel="balloon<?php echo md5($text); ?>">
			<img src="components/com_bindex/images/info.png" alt="info" border="0" />
		</a>
		
		<div id="balloon<?php echo md5($text); ?>" class="balloonstyle">
			<img src="components/com_bindex/images/info.png" alt="" style="float: right; margin-left: 5px;" />
			<?php echo $tooltip; ?>
		</div>

		<?php
		
	} //function
	
	function _drawRequired ()
	{
		?>
		&nbsp;(<span style="color: red; font-weight:bold;">*</span>)
		<?php
	} //function
	
	function drawEditImage ($link_edit)
	{ 
		?>
		<a href="<?php echo $link_edit; ?>">
			<img src="components/com_bindex/images/edit.png" border="0" alt="<?php echo BI_EDIT; ?>" title="<?php echo BI_EDIT; ?>" />
		</a>
		<?php
	} //function

	function drawSelectListBereiche ( $id_selected = 0, $submit_this = FALSE, $formname = 'adminForm' )
	{
		global $database;
		global $biConfig;
		$query = "SELECT *" .
			"\n FROM #__bindex_bereiche" .
			"\n WHERE `published` = '1'";
		$database->setQuery($query);
		$bereiche_ids = $database->loadObjectList();
		$order[] = mosHTML::makeOption( '', '' );
		foreach( $bereiche_ids as $b_id )
		{
			$order[] = mosHTML::makeOption( $b_id->id, getValueBereich ($b_id->id, $biConfig->ini_language) );
		} //foreach
		$submit = ($submit_this) ? 'onchange="document.'.$formname.'.submit();"' : '';
		$list = mosHTML::selectList( $order, 'id_bereich', 'class="inputbox" size="1"'.$submit, 'value', 'text', $id_selected );
		echo $list;		
	} //function
	
	/**
	 * @param int $id_selected
	 * @return HtmlSelectBox 
	 */
	function drawSelectListStaedte ( $id_selected = 0, $submit_this = FALSE, $form_name = 'adminForm' )
	{
		global $database;
		global $biConfig;
global $DBG;
		
		$query = "SELECT `id_stadt`, `value`" .
					"\n FROM #__bindex_staedte_data" .
					"\n WHERE `language` = '{$biConfig->ini_language}'" .
					"\n ORDER BY `value`";
		$database->setQuery($query);
		$s_namen = $database->loadObjectList();
$DBG->query($query);		
		if( $submit_this )	$order[] = mosHTML::makeOption( '', '' );
		
		foreach( $s_namen as $s_name )
		{
			$order[] = mosHTML::makeOption( $s_name->id_stadt, $s_name->value );
		}
		$submit = ($submit_this) ? ' onchange="document.'.$form_name.'.submit();"' : '';
		$list = mosHTML::selectList( $order, 'id_stadt', 'class="inputbox" size="1"'.$submit, 'value', 'text', $id_selected );
		echo $list;
	} //function
	
	function drawLanguageTHs ()
	{
		global $langActive;

		foreach( $langActive as $language )
		{	?>
			<th>
				<div class="bi_langbox">
					<?php $this->_drawFlagImage($language->iso); ?>
					<br />
					<?php echo $language->name; ?>
				</div>
			</th>
			<?php
		} //foreach
	} //function
	
	function drawCopyButtonJS ( $field_name, $language_code )
	{
		global $biConfig;
		if( $language_code != $biConfig->ini_language )
		{
		
		$JS_from_field ='document.BiForm.'.$field_name.'_'.$biConfig->ini_language;
		$JS_to_field = 'document.BiForm.'.$field_name.'_'.$language_code;
		$JS_action = "$JS_to_field.value = $JS_from_field.value; ";
//		$JS_action_down = "swap('img_copy_".$field_name."', 'components/com_bindex/images/edit.png')";
		
		$JS_action_click = '';//"document.images['img_copy_".$field_name."'].src='components/com_bindex/images/edit.png'";//"('img_copy_".$field_name."', 'components/com_bindex/images/edit.png')";
		$JS_action_down = "document.images['img_copy_".$field_name.'_'.$language_code."'].src='components/com_bindex/images/arrow-right-icon-w.gif'; ".$JS_action;
		$JS_action_up = "swap('img_copy_".$field_name.'_'.$language_code."', 'components/com_bindex/images/login_r.png')";
		?>
		<a onmousedown="<?php echo $JS_action_down; ?>" onmouseup="<?php echo $JS_action_up; ?>" onclick="<?php echo $JS_action_click; ?>">
			<img src="components/com_bindex/images/login_r.png" name="img_copy_<?php echo $field_name; ?>_<?php echo $language_code; ?>" alt="copy" />
		</a>
		<?php
		} else
		{
			?>
			<img src="components/com_bindex/images/filler1px.png" alt="copy" />
			<?php
		}
	} //function
		
	function NiK_footer ()
	{
		global $biConfig;
		?>
		<div class="bi_footer" align="center">
			<?php
			echo $biConfig->AppName.'&nbsp;';
			if( canEdit() ) echo $biConfig->AppVersion;
			?>
			&nbsp;powered by <a href="http://www.nik-it.de" target="_blank">NiK-IT.de</a>
		</div>
		<?php
	} //function
	
	function _formConfigTab_Main ( $lists )
	{
		global $biConfig;
		?>
			<div class="jwts_tabbertab" title="">
				<h2><a href="javascript:void(null);" name="advtab">
Main</a></h2>
				<table cellpadding="4" cellspacing="0" border="0" class="bi_form">
					<tr>
						<td width="10%" align="center"><?php $this->drawInfoTT('INFO...'); ?></td>
						<td align="right">show_menu_not_logged_in</td>
						<td align="left"><input type="checkbox" name="show_menu_not_logged_in" value="1" <?php if( $biConfig->showMenuNotLoggedIn == 1 ) echo 'checked="checked"'; ?> /></td>
					</tr>
					<tr>
						<td width="10%" align="center"><?php $this->drawInfoTT('INFO...'); ?></td>
						<td align="right">menu buttons</td>
						<td align="left"><?php echo $lists['buttons_show']; ?></td>
					</tr>
					<tr>
						<td width="10%" align="center"><?php $this->drawInfoTT('INFO...'); ?></td>
						<td align="right">App iconset</td>
						<td align="left" colspan="2"><?php echo $lists['icon_set']; ?></td>
					</tr>
						<tr>
							<td width="10%" align="center"><?php $this->drawInfoTT('INFO...'); ?></td>
							<td align="left" colspan="2">
								<strong>Debugging</strong><?php echo $lists['DEBUG']; ?>
								<strong>Logging</strong><?php echo $lists['LOG']; ?>
							</td>
						</tr>
				
				</table>
			</div>
		
		<?php
	} //function

	function _formConfigTab_Viewing ( $lists )
	{
		global $biConfig;
		?>
			<div class="jwts_tabbertab" title="">
				<h2><a href="javascript:void(null);" name="advtab">Viewing</a></h2>
				<table cellpadding="4" cellspacing="0" border="0" class="bi_form">
					<tr>
						<th colspan="3"><strong>Templates</strong></th>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">Item view template</td>
						<td align="left" colspan="2"><?php echo $lists['template_item']; ?></td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">Directory template</td>
						<td align="left" colspan="2"><?php echo $lists['template_directory']; ?></td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">App template</td>
						<td align="left" colspan="2"><?php echo $lists['template_app']; ?></td>
					</tr>
						
					<tr>
						<th colspan="3"><strong>Viewing</strong></th>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">ViewMode</td>
						<td align="left" colspan="2"><?php echo $lists['view_mode']; ?></td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">list_limit</td>
						<td align="left" colspan="2"><input class="inputbox" type="text" name="list_limit" size="15" value="<?php echo $biConfig->list_limit; ?>" /></td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...a'); ?></td>
						<td align="left" width="185">directory_items_in_row</td>
						<td align="left" colspan="2"><input class="inputbox" type="text" name="directory_items_in_row" size="15" value="<?php echo $biConfig->directory_items_in_row; ?>" /></td>
					</tr>
				
				</table>
			</div>

		<?php
	} //function
	
	function _formConfigTab_Editing ( $lists )
	{
		global $biConfig;
		?>
			<div class="jwts_tabbertab" title="">
				<h2><a href="javascript:void(null);" name="advtab">Editing</a></h2>
				<table cellpadding="4" cellspacing="0" border="0" class="bi_form">
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...b'); ?></td>
						<td align="left" width="185">Editor Area</td>
						<td align="left">
							Width: <input class="inputbox" type="text" name="editorWidth" size="3" value="<?php echo $biConfig->editorWidth; ?>" /> px</td>
						<td align="left">Height: <input class="inputbox" type="text" name="editorHeight" size="3" value="<?php echo $biConfig->editorHeight; ?>" /> px</td>
					</tr>
				</table>
			</div>

		<?php
	} //function
	
	function _formConfigTab_ImageUpload ( $lists )
	{
		global $biConfig;
		?>
			<div class="jwts_tabbertab" title="">
				<h2><a href="javascript:void(null);" name="advtab">Image upload</a></h2>
				<table cellpadding="4" cellspacing="0" border="0" width="100%" class="bi_form">
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...c'); ?></td>
						<td align="left" width="185">imagesFolder:</td>
						<td align="left">
							<input class="inputbox" type="text" name="images_folder" size="27" value="<?php echo $biConfig->imagesFolder; ?>" />
							<?php if( $biConfig->imagesFolder ) echo bi_is_writeable( $biConfig->absolutePath.$biConfig->imagesFolder ); ?>
						</td>
						<td align="left">imagesFolder</td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...c'); ?></td>
						<td align="left" width="185">maxFileSize:</td>
						<td align="left"><input class="inputbox" type="text" name="max_file_size" size="5" value="<?php echo $biConfig->maxFileSize; ?>" /> kB</td>
						<td align="left">Maximum allowed FileSize:</td>
					</tr>
					<tr>
						<td colspan="4"><strong>Resize uploaded images to:</strong></td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...c'); ?></td>
						<td align="left" width="185">Images:</td>
						<td align="left">
						Width: <input class="inputbox" type="text" name="img_width" size="3" value="<?php echo $biConfig->imgWidth; ?>" />
						Height: <input class="inputbox" type="text" name="img_height" size="3" value="<?php echo $biConfig->imgHeight; ?>" /> px</td>
						<td align="left">&nbsp;</td>
					</tr>
					<tr>
						<td align="left"><?php $this->drawInfoTT('INFO...c'); ?></td>
						<td align="left" width="185">Thumbnails:</td>
						<td align="left">
						Width: <input class="inputbox" type="text" name="img_tmb_width" size="3" value="<?php echo $biConfig->imgTmbWidth; ?>" />
						Height: <input class="inputbox" type="text" name="img_tmb_height" size="3" value="<?php echo $biConfig->imgTmbHeight; ?>" /> px</td>
						<td align="left">&nbsp;</td>
					</tr>
				</table>
			</div>

		<?php
	} //function
	
	function _formConfigTab_GoogleMaps ( $lists )
	{
		global $biConfig;
		?>
			<div class="jwts_tabbertab" title="">
				<h2><a href="javascript:void(null);" name="advtab">Google Maps</a></h2>
				<?php $this->drawInfoTT('NOT WORKING !!! enabled by default..'); ?>
				<input type="checkbox" name="enable_gmaps" id="enable_gmaps" value="checked" /><label for="enable_gmaps"> Use Google maps ??</label>
				<hr />

				<div class="jwts_tabber" id="jwts_tab1">

					<div class="jwts_tabbertab" title="">
						<h2><a href="javascript:void(null);" name="advtab">General</a></h2>

						<table cellpadding="4" cellspacing="0" border="0" class="bi_form">
							<tr>
							<td align="left"><?php $this->drawInfoTT('INFO...d'); ?></td>
								<td align="left"><strong>API Key</strong></td>
								<td align="left">
									<input class="inputbox" type="text" name="gmap_key" size="50"
									 value="<?php echo $biConfig->GMapKey; ?>" />
								</td>
							</tr>
							<tr>
				<th colspan="3">Icon path</th>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...d'); ?></td>
								<td>Standard Icon path</td>
								<td>
									<input class="inputbox" type="text" name="gmap_g_basepath" size="50"
									 value="<?php echo $biConfig->GMapGBasePath; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...d'); ?></td>
								<td>Custom Icon path</td>
								<td>
									<input class="inputbox" type="text" name="gmap_custom_basepath" size="50"
									 value="<?php echo $biConfig->GMapCustomBasePath; ?>" />
								</td>
							</tr>
						</table>
					</div>
					<div class="jwts_tabbertab" title="">
						<h2><a href="javascript:void(null);" name="advtab">Main Map</a></h2>
						
						<table>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...e'); ?></td>
								<td>Center Lat</td>
								<td>
									<input class="inputbox" type="text" name="gmap_main_center_lat" size="50"
									 value="<?php echo $biConfig->GMapMainCenterPointLat; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...e'); ?></td>
								<td>Center Long</td>
								<td>
									<input class="inputbox" type="text" name="gmap_main_center_lng" size="50"
									 value="<?php echo $biConfig->GMapMainCenterPointLng; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...e'); ?></td>
								<td>Width</td>
								<td>
									<input class="inputbox" type="text" name="gmap_main_width" size="50"
									 value="<?php echo $biConfig->GMapMainWidth; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...e'); ?></td>
								<td>Height</td>
								<td>
									<input class="inputbox" type="text" name="gmap_main_height" size="50"
									 value="<?php echo $biConfig->GMapMainHeight; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...e'); ?></td>
								<td>Zoom</td>
								<td>
									<input class="inputbox" type="text" name="gmap_main_zoom" size="50"
									 value="<?php echo $biConfig->GMapMainZoom; ?>" />
								</td>
							</tr>
						</table>
					</div>
					<div class="jwts_tabbertab" title="">
						<h2><a href="javascript:void(null);" name="advtab">Map in Lightbox</a></h2>
						<table>
							<tr>
									<td align="left"><?php $this->drawInfoTT('INFO...f'); ?></td>
								<td align="left" width="185">gmap_show_popup</td>
								<td align="left" colspan="2"><input type="checkbox" name="gmap_show_popup" value="1" <?php if( $biConfig->GMapShowPopup == 1 ) echo 'checked="checked"'; ?> /></td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...f'); ?></td>
								<td>Width</td>
								<td>
									<input class="inputbox" type="text" name="gmap_popup_width" size="50"
									 value="<?php echo $biConfig->GMapPopupWidth; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...f'); ?></td>
								<td>Height</td>
								<td>
									<input class="inputbox" type="text" name="gmap_popup_height" size="50"
									 value="<?php echo $biConfig->GMapPopupHeight; ?>" />
								</td>
							</tr>
							<tr>
								<td align="left"><?php $this->drawInfoTT('INFO...ffff'); ?></td>
								<td>Zoom</td>
								<td>
									<input class="inputbox" type="text" name="gmap_popup_zoom" size="50"
									 value="<?php echo $biConfig->GMapPopupZoom; ?>" />
								</td>
							</tr>
						</table>
					</div>
				</div>
			</div><!--close google tab div-->
		<?php
	} //function
	
	function formConfig( $lists )
	{
		global $mainframe, $Itemid;
		global $biConfig;
		
  		$this->load_JS_Tabs_Slides();
  		$this->loadJS_Tooltips();

		$link_back = 'index.php?option=com_bindex&amp;Itemid='.$Itemid.'&amp;task=save_config';

		HTML_BIndex::biHeader(BI_SETTINGS);
		
		?>
		<form action="<?php echo $link_back; ?>" method="post" name="adminForm">

			<!-- tabber start -->
			<div class="jwts_tabber" id="jwts_tab1">
				<?php
				$this->_formConfigTab_Main($lists);
				$this->_formConfigTab_Viewing($lists);
				$this->_formConfigTab_Editing($lists);
				$this->_formConfigTab_ImageUpload($lists);
				$this->_formConfigTab_GoogleMaps($lists);
				
				?>
			</div>
			<!-- tabber closing -->
			
			<br /><br />
			<div align="center">
					<?php $this->_Button('javascript: document.adminForm.submit();', 'save', BI_SAVE ); ?>
			</div>
	
		</form>

		<?php
	} //function
	
	
	function msgError ( $text )
	{ ?>
		<div class="bi_msg_error">
			<?php echo $text; ?>
		</div>
		<?php
	} //function
	function msgInfo ( $text )
	{ ?>
		<div class="bi_msg_info">
			<?php echo $text; ?>
		</div>
		<?php
	} //function

	function msgAlert ( $text )
	{ ?>
		<div class="bi_msg_alert">
			<?php echo $text; ?>
		</div>
		<?php
	} //function
	
	function help ( $help )
	{
		$this->msgInfo(BI_NOT_READY);
		switch( $help )
		{
			case 'item_defs':
				$this->_help_item_defs();
			break;
			
			case 'credits':
				$this->credits();
			break;
		
			default:
				echo 'undefined..'.$help;
			break;
		} //switch
				$link_credits = 'index2.php?option=com_bindex&amp;task=help&amp;help=credits';
echo '<div align="right"><a href="'.$link_credits.'">Credits</a></div>';		
	} //function
	
	function _help_item_defs ()
	{
		?>
		
  <table border="1" width="100%">
    <tr>
      <th>Language definition</th><th>Item code</th>
    </tr>
    <tr>
      <td>BI_NAME</td><td>$item->name();</td>
    </tr>
    <tr>
      <td>t10</td><td>t11</td>
    </tr>
    <tr>
      <td>BI_MAP_LOCATION</td><td>$item->mapLocation( 'xxx', 'xxx' );<br />width (% / px), height (px)</td>
    </tr>    
  </table>
  
  
		<?php
	} //function
	
	
	/**
	 * 
	 * Loader for javascript
	 * 
	 */
	
	function loadJS_Tooltips()
	{
		global $mainframe;
		global $biConfig;
	
		/***********************************************
		* Rich HTML Balloon Tooltip- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
		* This notice MUST stay intact for legal use
		* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
		***********************************************/
		$mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="components/com_bindex/includes/js/tooltips/balloontip.css" />');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$biConfig->liveSite.'/components/com_bindex/includes/js/tooltips/balloontip.js"></script>' );
	} //function
	
	function load_JS_Lightbox()
	{
		global $mainframe;
		global $biConfig;
		
		$basepath = $biConfig->liveSite.'/components/com_bindex/includes/js/lightbox/';
		#load JS
		
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/prototype.js"></script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/scriptaculous.js?load=effects"></script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="'.$basepath.'js/lightbox.js"></script>');

		$mainframe->addCustomHeadTag('<link rel="stylesheet" href="components/com_bindex/includes/js/lightbox/css/lightbox.css" type="text/css" media="screen" />');
	} //function
	
	function load_JS_Tabs_Slides()
	{
		global $mainframe;
		global $loadJWTSscripts;
		global $biConfig;
		
$N = "\n";
  		if(!$loadJWTSscripts)
  		{
			$loadJWTSscripts=1;
			$base_path = '/components/com_bindex/includes/js/plugin_jw_ts/';
			$header = 
			 $N.'<!-- JoomlaWorks \"Tabs &amp; Slides\" Plugin (v2.3) starts here -->'
			.$N.'<style type="text/css" media="screen">'
			.$N.'  @import "'.$biConfig->liveSite.$base_path.'tabs_slides.css";'
			.$N.'</style>'
			.$N.'<style type="text/css" media="print">.jwts_tabbernav{display:none;}</style>'
			.$N.'<script type="text/javascript">var jwts_slideSpeed=30; var jwts_timer=10;</script>'
			.$N.'<script type="text/javascript" src="'.$biConfig->liveSite.$base_path.'tabs_slides_comp.js"></script>'
			.$N.'<script type="text/javascript" src="'.$biConfig->liveSite.$base_path.'tabs_slides_def_loader.js"></script>'
			.$N.'<!-- JoomlaWorks \"Tabs & Slides\" Plugin (v2.3) ends here -->';

			$mainframe->addCustomHeadTag($header);
		}//if
	} //function
	
	function load_JS_CodePress ()
	{
		global $mainframe;
		
		$mainframe->addCustomHeadTag('<script type="text/javascript" src="components/com_bindex/includes/js/codepress/codepress.js"></script>');  
	} //function
	
	/**
	 * last but not least :)
	 * 
	 * CREDITS
	 * 
	 */
	function credits ()
	{
		global $biConfig;
		
		echo '<div style="padding: 5px;">';
		echo $biConfig->AppName.'&nbsp;' .  $biConfig->AppVersion.'<br />';
		?>
		<p>
		We are proud to include the following scripts:
		</p>
		<ul>
			<li>
				<strong>JW Tabs &amp; Slides Plugin (v2.3)</strong><br />
				Authors: Fotis Evangelou - George Chouliaras<br />
				 Copyright (c) 2006 - 2007 JoomlaWorks.gr - http://www.joomlaworks.gr

			</li>
			<li>
			 CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/<br />
 
 Copyright (C) 2006 Fernando M.A.d.S.

			</li>
			<li>
			Lightbox v2.02<br />
by Lokesh Dhakar - http://www.huddletogether.com<br />
3/31/06<br />
<br />
	hacked to use iframe for non-jpeg urls<br />
	by Tim Morgan - http://timmorgan.org<br />
	8/9/06<br />
<br />
	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox2/<br />
	...and...<br />
	http://mpov.wordpress.com/2006/08/08/lightbox-with-iframes/<br />
<br />
	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
			
			</li>
			<li>
			//Rich HTML Balloon Tooltip: http://www.dynamicdrive.com/dynamicindex5/balloontooltip.htm
//Created: September 10th, 2006
			</li>
			<li>
			Google Maps ...
			</li>
		</ul>
	<div>
		<?php
	} //function
	
}//class

?>
